<?php

use think\migration\Migrator;
use think\migration\db\Column;

class SystemMenu extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
		$table = $this->table('system_menu',['engine'=>'InnoDb']);
		$table->addColumn('name','string',['limit'=>15,'default'=>'','comment'=>'菜单名称'])
			->addColumn('icon','string',['limit'=>25,'default'=>'','comment'=>'图标'])
			->addColumn(Column::integer('pid')->setDefault(0)->setComment('上级菜单')->setLimit(11))
			->addColumn(Column::integer('sort')->setDefault(0)->setComment('排序')->setLimit(11))
			->addColumn(Column::integer('deletetime')->setDefault(null)->setNull(true)->setComment('删除时间')->setLimit(11))
			->addColumn(Column::integer('createtime')->setDefault(0)->setComment('添加时间')->setLimit(11))
			->addColumn(Column::integer('updatetime')->setDefault(0)->setComment('添加时间')->setLimit(11))
			->addColumn(Column::string('link')->setDefault('')->setComment('路径')->setLimit(50))
			->addColumn(Column::string('controller')->setDefault('')->setComment('控制器')->setLimit(50))
			->addColumn(Column::string('action')->setDefault('')->setComment('方法')->setLimit(50))
			->addColumn(Column::tinyInteger('is_show')->setDefault(1)->setComment('是否显示 0不显示')->setLimit(1))
			->addColumn(Column::tinyInteger('type')->setDefault(1)->setComment('类型 0菜单组 1菜单 2按钮')->setLimit(1))
			->addIndex(['controller','action','link','name'])
			->create();
    }
}
